アニメーション
指定のフレームのパラメータからキー フレームを削除します。 このコマンドは、アニメーション ポップアップ メニューから
Remove Key を選択する操作、またはデフォルト キーボード
レイアウトで[Shift]+[K]キーを押す操作に相当するスクリプトです。
注: キーのいずれかが削除できない場合、コマンドは siErrCancelled エラーを発行します。詳細については、siErrorValueEnum を参照してください。
エラーを避けるために、VBScript の「On Error Resume Next...On Error Goto
0」ステートメントまたは JScript の「try()...catch(e)」命令文を使用して RemoveKey
へのコールをラップしてください。
RemoveKey( [InputObjs], [Time], [Tolerance], [Layer] ); |
| パラメータ | タイプ | 詳細 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| InputObjs | 文字列 | アニメート可能なパラメータのリスト (例:
cone*/kine.local.pos)。
デフォルト値:現在選択され、マーキングされているパラメータ |
||||||||
| Time | Number | このフレームからキー フレームが削除されます。
デフォルト値: 現在のフレーム |
||||||||
| Tolerance | ダブル | フレームの許容範囲
デフォルト値:最も近い 0.5 フレーム(-1)
|
||||||||
| レイヤ | Integer | 削除するキーを含むアニメーション レイヤ
デフォルト値:現在のアニメーションレイヤ(-1) |
'
' This example sets up some animation on the X position of a sphere, moves to the next key frame,
' prints out the key information for this parameter, removes the next key and prints out the
' key information again.
'
' Set up an object to animate
set oGlobe = CreatePrim( "Sphere", "NurbsSurface", "MySphere" )
' Set the maximum frame number to 40
SetValue "PlayControl.Out", 40
' Set some keys on XPos at various frames
SaveKey oGlobe & ".kine.local.posx", 1, -9.0
SaveKey oGlobe & ".kine.local.posx", 10, 3.0
SaveKey oGlobe & ".kine.local.posx", 30,-3.0
SaveKey oGlobe & ".kine.local.posx", 40, 9.0
' Return to frame 1
SetValue "PlayControl.Current", 1
' Goto key at frame 10
NextKey oGlobe & "/kine.local.pos"
' Print out key info for the globe's position in X before
' removing the next key
WhereAmI oGlobe
' Remove key at frame 30 (next key)
if RemoveNextKey( oGlobe & "/kine.local.pos" ) then
LogMessage "Successfully removed the key."
else
LogMessage "This is the last key."
end if
' Print out key info for the globe's position in X after
' removing the next key
WhereAmI oGlobe
' Goto NextKey (at frame 40 now)
NextKey ( oGlobe & "/kine.local.pos" )
' This function removes the next key (provided that there is a next key to remove)
' and returns a boolean value indicating whether it could remove the key or not.
function RemoveNextKey ( in_parameter )
' Check if there is another key (if there is no next key, NextKey returns "1.#INF")
if ( NextKey( in_parameter ) <> "1.#INF" ) then
RemoveKey in_parameter
RemoveNextKey = true
exit function
end if
RemoveNextKey = false
end function
' This subroutine prints out the total number of keys on the object, and then prints
' the frame number and value for each key in the collection.
sub WhereAmI( in_object )
if TypeName( in_object ) <> "Nothing" then
' Get the fcurve object that is attached to the XPos parameter
set oAnimationFC = in_object.posx.Source
' From the fcurve object you can get the list of keys
set oFCKeys = oAnimationFC.Keys
' Make sure there are some keys on the parameter
if oFCKeys.Count > 0 then
' Print the total number of keys now present on this parameter
LogMessage "Number of keys on the " & in_object & " object: " & oFCKeys.Count
' Loop through the collection of keys, printing out the key index & its frame number
for each k in oFCKeys
LogMessage "Key [" & k.Index & "] is set on Frame[" & k.Time & "] with a value of " & k.Value
next
end if
end if
end sub
' Output of above script:
'...before key was removed
'INFO : "Number of keys on the MySphere object: 4"
'INFO : "Key [0] is set on Frame[1] with a value of -9"
'INFO : "Key [1] is set on Frame[10] with a value of 3"
'INFO : "Key [2] is set on Frame[30] with a value of -3"
'INFO : "Key [3] is set on Frame[40] with a value of 9"
'
'INFO : "Successfully removed the key."
'
'...after key was removed
'INFO : "Number of keys on the MySphere object: 3"
'INFO : "Key [0] is set on Frame[1] with a value of -9"
'INFO : "Key [1] is set on Frame[10] with a value of 3"
'INFO : "Key [2] is set on Frame[40] with a value of 9"
|